//
//  OnlineOLDetailModel.m
//  ShangHaiHuDongApp
//
//  Created by apple on 17/9/4.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "OnlineOLDetailModel.h"

@implementation OnlineOLDetailModel

-(void)ybCalculateCellSubViewSize{
    if ( self.START_TIME.length > 0) {
        self.START_TIME = [NSDateFormatter stringMonthAndHourAndMintueWithDate:[NSString stringWithFormat:@"%@" , self.START_TIME]];
    }
    NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle1 setLineSpacing:ItemHeight * 14];
    //计算标题高度
    NSMutableAttributedString * aaa = [[NSMutableAttributedString alloc]initWithString:self.titleString];
    self.titleSize = [self.titleString boundingRectWithSize:CGSizeMake(([UIScreen zj_screenWith] - ItemWidth * 48), CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : LYPFONT(16) , NSParagraphStyleAttributeName : paragraphStyle1} context:nil].size;
    
//    self.titleAttributeString = [[NSMutableAttributedString alloc]initWithString:self.titleString];
    [aaa addAttribute:NSFontAttributeName value:LYPFONT(16) range:NSMakeRange(0, self.titleString.length)];
    [aaa addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, self.titleString.length)];
    self.titleAttributeString = [aaa copy];
    //计算内容高度
    NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle setLineSpacing:ItemHeight * 14];
    CGSize twoFontSize = [@"张张" boundingRectWithSize:CGSizeMake(([UIScreen zj_screenWith] - ItemWidth * 48), CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : LYPFONT(16) , NSParagraphStyleAttributeName : [paragraphStyle copy]} context:nil].size;
    paragraphStyle.firstLineHeadIndent = twoFontSize.width;
    self.contentSize = [self.contentString boundingRectWithSize:CGSizeMake([UIScreen zj_screenWith] - ItemWidth * 48, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : LYPFONT(16) , NSParagraphStyleAttributeName : paragraphStyle} context:nil].size;
    //设置内容属性字符串
    
    self.contentAttributeString = [[NSMutableAttributedString alloc]initWithString:self.contentString];
    [self.contentAttributeString addAttribute:NSFontAttributeName value:LYPFONT(16) range:NSMakeRange(0, self.contentString.length)];
    [self.contentAttributeString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, self.contentString.length)];
    if ((self.contentSize.width + twoFontSize.width) <= ([UIScreen zj_screenWith] - ItemWidth * 48)) {
        self.contentSize = CGSizeMake(self.contentSize.width + twoFontSize.width, self.contentSize.height);
    }
    //设置总高度
    self.totalHeight = ItemHeight * 139 + self.titleSize.height + self.contentSize.height ;
    
}

+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"titleString" : @"NAME",
             @"contentString" : @"DESCRIPTION",
             @"imageUrlString" : @"COVER_JSON.file_path"};
}

@end
